#!/bin/sh
#
#  -- https://android-autotool.googlecode.com/svn/trunk/selfcontain.sh --
#
#  Self Contain bash srcipt
#
#  Copyright 2011, Kyan He <kyan.ql.he@gmail.com>
#
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.


BINARY_START=`awk '/^__ARCHIVE_BELOW__/ { print NR + 1; exit 0; }' $0`

TMP_DIR=.tmp

mkdir $TMP_DIR
tail -n+$BINARY_START $0 | tar xz -C $TMP_DIR

# customiztion exec
if [ ! $# -eq 1 ];
then
    echo "Usage: $0 </path/to/apk>"
else
    # do something
fi
rm -rf $TMP_DIR

exit 0

# encapusolate ordinary data(gzip preferred) below, e.g.
# $ cat $data >>$this_file
__ARCHIVE_BELOW__

